class Product{
    constructor(name){
        this.name = name
    }
    init(){
        console.log(this.name);
    }
    fn1(){
        console.log('fn1');
    }
    fn2(){
        console.log('fn2');
    }
}
// 工厂模式：是用工厂方法代替new操作的一种模式
class Creator{
   create(name){
    return new Product(name)
   }
}

var creator = new Creator();
var p1 = creator.create('汉堡')
p1.init()
p1.fn1()
p1.fn2()
